/*
 * @copyright fxsen <br/>
 * @date 2022/4/14 16:43 <br/>
 * @email <a href="mailto:fxsen@foxmail.com">
 * @author fxsen
 */
package com.fxsen.commons.core.base.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fxsen.commons.core.base.common.mapper.CommonMapper;
import com.fxsen.commons.core.base.common.service.ICommonService;

import java.util.List;

/**
 * 接口实现基础类
 * @author fxsen
 * @date 2022/4/14 16:43
 * @email <a href="mailto:fxsen@foxmail.com">
 */
public class CommonServiceImpl<M extends CommonMapper<T>, T> extends ServiceImpl<M,T> implements ICommonService<T> {
    @Override
    public boolean isExist(String fieldName, Object value) {
        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(fieldName,value);
        return this.count(queryWrapper) > 0L;
    }

    @Override
    public List<T> getByPid(String id) {
        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("pid",id);
        return this.list(queryWrapper);
    }
}
